package com.trhui.mallbook.client;

import com.trhui.mallbook.domain.common.ApiRequest;
import com.trhui.mallbook.domain.common.BaseResponse;
import com.trhui.mallbook.domain.request.hf.HfCreateApplicationRequest;
import com.trhui.mallbook.domain.request.hf.HfMerchantEnterQueryRequest;
import com.trhui.mallbook.domain.request.hf.HfMerchantEnterRequest;
import com.trhui.mallbook.domain.request.hf.HfUpdateSettleAccountRequest;
import com.trhui.mallbook.domain.response.hf.HfCreateApplicationResponse;
import com.trhui.mallbook.domain.response.hf.HfMerchantEnterQueryResponse;
import com.trhui.mallbook.domain.response.hf.HfMerchantEnterResponse;
import com.trhui.mallbook.domain.response.hf.HfUpdateSettleAccountResponse;
import com.trhui.mallbook.enums.ChannelTypeEnum;
import com.trhui.mallbook.enums.ServerCodeEnum;

/**
 * 商户入驻相关接口
 *
 */
public class MerchantEnterClient extends AbstractClient {

    /**
     * 商户入驻
     *
     */
    public static BaseResponse<HfMerchantEnterResponse> merchantEnter(HfMerchantEnterRequest request) {
        ApiRequest apiRequest = new ApiRequest.ApiRequestBuild()
                .merOrderId(request.getMerOrderId())
                .merchantNo(request.getMerchantNo())
                .params(request)
                .serverCode(ServerCodeEnum.MERCHANT_ENTER)
                .channelType(ChannelTypeEnum.HF)
                .build();
        return post(apiRequest, HfMerchantEnterResponse.class);
    }

    /**
     * 商户入驻查询接口
     *
     */
    public static BaseResponse<HfMerchantEnterQueryResponse> merchantEnterQuery(HfMerchantEnterQueryRequest request) {
        ApiRequest apiRequest = new ApiRequest.ApiRequestBuild()
                .merOrderId(request.getMerOrderId())
                .merchantNo(request.getMerchantNo())
                .params(request)
                .serverCode(ServerCodeEnum.QUERY_MERCHANT_ENTRY)
                .channelType(ChannelTypeEnum.HF)
                .build();
        return post(apiRequest, HfMerchantEnterQueryResponse.class);
    }

    /**
     * 创建应用接口
     *
     */
    public static BaseResponse<HfCreateApplicationResponse> createApplication(HfCreateApplicationRequest request) {
        ApiRequest apiRequest = new ApiRequest.ApiRequestBuild()
                .merOrderId(request.getMerOrderId())
                .merchantNo(request.getMerchantNo())
                .params(request)
                .serverCode(ServerCodeEnum.CREATE_APPLICATION)
                .channelType(ChannelTypeEnum.HF)
                .build();
        return post(apiRequest, HfCreateApplicationResponse.class);
    }

    /**
     * 收款商户修改结算账户信息接口
     *
     */
    public static BaseResponse<HfUpdateSettleAccountResponse> updateSettleAccount(HfUpdateSettleAccountRequest request) {
        ApiRequest apiRequest = new ApiRequest.ApiRequestBuild()
                .merOrderId(request.getMerOrderId())
                .merchantNo(request.getMerchantNo())
                .params(request)
                .serverCode(ServerCodeEnum.UPDATE_SETTLEMENT_ACCOUNT)
                .channelType(ChannelTypeEnum.HF)
                .build();
        return post(apiRequest, HfUpdateSettleAccountResponse.class);
    }


}
